﻿package com.toncen.samepms.basic.action;

import com.toncen.samepms.basic.dao.OrganizationDao;
import com.toncen.samepms.basic.domain.Organization;
import com.toncen.samepms.common.AbstractDatabaseAction;

/**
 * 描述：表BASIC_ORGANIZATION的action文件
 * 
 * @author tch
 * 
 */
public class OrganizationAction<O,D> extends AbstractDatabaseAction<Organization, OrganizationDao<Organization>> {
	/**
	 * 序列号
	 */
	private static final long serialVersionUID = 1331527609455L;

	public OrganizationAction() throws Exception {
		super();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.toncen.samepms.common.AbstractAction#prepareOnDoEdit()
	 */
	@Override
	public void prepareOnDoEdit() throws Exception {
		super.prepareOnDoEdit();
		getDomain().setParent(getDao().find(getDomain().getParent()));
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.toncen.samepms.common.AbstractAction#prepareOnDoNew()
	 */
	@Override
	public void prepareOnDoNew() throws Exception {
		super.prepareOnDoNew();
		if (getDomain().getParent() == null) {
			getDomain().setParent(getCurrentOrganization());
		}
		getDomain().setParent(getDao().find(getDomain().getParent()));
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.toncen.samepms.common.AbstractAction#prepareOnDoView()
	 */
	@Override
	public void prepareOnDoView() throws Exception {
		super.prepareOnDoView();
		getDomain().setParent(getDao().find(getDomain().getParent()));
	}

}
